<?php
	/**
	 * The abstract TableItemGen class defined here is
	 * code-generated and contains all the basic CRUD-type functionality as well as
	 * basic methods to handle relationships and index-based loading.
	 *
	 * To use, you should use the TableItem subclass which
	 * extends this TableItemGen class.
	 *
	 * Because subsequent re-code generations will overwrite any changes to this
	 * file, you should leave this file unaltered to prevent yourself from losing
	 * any information or code changes.  All customizations should be done by
	 * overriding existing or implementing new methods, properties and variables
	 * in the TableItem class.
	 * 
	 * @package My Application
	 * @subpackage GeneratedDataObjects
	 * @property-read integer $Id the value for intId (Read-Only PK)
	 * @property string $Itemname the value for strItemname 
	 * @property string $Itemnamejp the value for strItemnamejp 
	 * @property string $Description1 the value for strDescription1 
	 * @property string $Description2 the value for strDescription2 
	 * @property integer $Price the value for intPrice (Not Null)
	 * @property integer $TaxWithin the value for intTaxWithin 
	 * @property integer $LicenseDay the value for intLicenseDay 
	 * @property string $Subscription the value for strSubscription (Not Null)
	 * @property string $Image the value for strImage 
	 * @property string $Simage the value for strSimage 
	 * @property QDateTime $SuspendDate the value for dttSuspendDate 
	 * @property string $Suspended the value for strSuspended (Not Null)
	 * @property string $Active the value for strActive (Not Null)
	 * @property-read TableItemGet $_TableItemGetAsItem the value for the private _objTableItemGetAsItem (Read-Only) if set due to an expansion on the table_item_get.item_id reverse relationship
	 * @property-read TableItemGet[] $_TableItemGetAsItemArray the value for the private _objTableItemGetAsItemArray (Read-Only) if set due to an ExpandAsArray on the table_item_get.item_id reverse relationship
	 * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
	 */
	class TableItemGen extends QBaseClass {

		///////////////////////////////////////////////////////////////////////
		// PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
		///////////////////////////////////////////////////////////////////////
		
		/**
		 * Protected member variable that maps to the database PK Identity column table_item.id
		 * @var integer intId
		 */
		protected $intId;
		const IdDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_item.itemname
		 * @var string strItemname
		 */
		protected $strItemname;
		const ItemnameMaxLength = 100;
		const ItemnameDefault = null;


		/**
		 * Protected member variable that maps to the database column table_item.itemnamejp
		 * @var string strItemnamejp
		 */
		protected $strItemnamejp;
		const ItemnamejpMaxLength = 100;
		const ItemnamejpDefault = null;


		/**
		 * Protected member variable that maps to the database column table_item.description1
		 * @var string strDescription1
		 */
		protected $strDescription1;
		const Description1MaxLength = 255;
		const Description1Default = null;


		/**
		 * Protected member variable that maps to the database column table_item.description2
		 * @var string strDescription2
		 */
		protected $strDescription2;
		const Description2MaxLength = 255;
		const Description2Default = null;


		/**
		 * Protected member variable that maps to the database column table_item.price
		 * @var integer intPrice
		 */
		protected $intPrice;
		const PriceDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_item.tax_within
		 * @var integer intTaxWithin
		 */
		protected $intTaxWithin;
		const TaxWithinDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_item.license_day
		 * @var integer intLicenseDay
		 */
		protected $intLicenseDay;
		const LicenseDayDefault = 0;


		/**
		 * Protected member variable that maps to the database column table_item.subscription
		 * @var string strSubscription
		 */
		protected $strSubscription;
		const SubscriptionMaxLength = 1;
		const SubscriptionDefault = 'n';


		/**
		 * Protected member variable that maps to the database column table_item.image
		 * @var string strImage
		 */
		protected $strImage;
		const ImageDefault = null;


		/**
		 * Protected member variable that maps to the database column table_item.simage
		 * @var string strSimage
		 */
		protected $strSimage;
		const SimageDefault = null;


		/**
		 * Protected member variable that maps to the database column table_item.suspend_date
		 * @var QDateTime dttSuspendDate
		 */
		protected $dttSuspendDate;
		const SuspendDateDefault = null;


		/**
		 * Protected member variable that maps to the database column table_item.suspended
		 * @var string strSuspended
		 */
		protected $strSuspended;
		const SuspendedMaxLength = 1;
		const SuspendedDefault = null;


		/**
		 * Protected member variable that maps to the database column table_item.active
		 * @var string strActive
		 */
		protected $strActive;
		const ActiveMaxLength = 1;
		const ActiveDefault = 'y';


		/**
		 * Private member variable that stores a reference to a single TableItemGetAsItem object
		 * (of type TableItemGet), if this TableItem object was restored with
		 * an expansion on the table_item_get association table.
		 * @var TableItemGet _objTableItemGetAsItem;
		 */
		private $_objTableItemGetAsItem;

		/**
		 * Private member variable that stores a reference to an array of TableItemGetAsItem objects
		 * (of type TableItemGet[]), if this TableItem object was restored with
		 * an ExpandAsArray on the table_item_get association table.
		 * @var TableItemGet[] _objTableItemGetAsItemArray;
		 */
		private $_objTableItemGetAsItemArray = array();

		/**
		 * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
		 * columns from the run-time database query result for this object).  Used by InstantiateDbRow and
		 * GetVirtualAttribute.
		 * @var string[] $__strVirtualAttributeArray
		 */
		protected $__strVirtualAttributeArray = array();

		/**
		 * Protected internal member variable that specifies whether or not this object is Restored from the database.
		 * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
		 * @var bool __blnRestored;
		 */
		protected $__blnRestored;




		///////////////////////////////
		// PROTECTED MEMBER OBJECTS
		///////////////////////////////





		///////////////////////////////
		// CLASS-WIDE LOAD AND COUNT METHODS
		///////////////////////////////

		/**
		 * Static method to retrieve the Database object that owns this class.
		 * @return QDatabaseBase reference to the Database object that can query this class
		 */
		public static function GetDatabase() {
			return QApplication::$Database[1];
		}

		/**
		 * Load a TableItem from PK Info
		 * @param integer $intId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem
		 */
		public static function Load($intId, $objOptionalClauses = null) {
			// Use QuerySingle to Perform the Query
			return TableItem::QuerySingle(
				QQ::AndCondition(
					QQ::Equal(QQN::TableItem()->Id, $intId)
				),
				$objOptionalClauses
			);
		}

		/**
		 * Load all TableItems
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		 */
		public static function LoadAll($objOptionalClauses = null) {
			if (func_num_args() > 1) {
				throw new QCallerException("LoadAll must be called with an array of optional clauses as a single argument");
			}
			// Call TableItem::QueryArray to perform the LoadAll query
			try {
				return TableItem::QueryArray(QQ::All(), $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count all TableItems
		 * @return int
		 */
		public static function CountAll() {
			// Call TableItem::QueryCount to perform the CountAll query
			return TableItem::QueryCount(QQ::All());
		}




		///////////////////////////////
		// QCUBED QUERY-RELATED METHODS
		///////////////////////////////

		/**
		 * Internally called method to assist with calling Qcubed Query for this class
		 * on load methods.
		 * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
		 * @param boolean $blnCountOnly only select a rowcount
		 * @return string the query statement
		 */
		protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			// Create/Build out the QueryBuilder object with TableItem-specific SELET and FROM fields
			$objQueryBuilder = new QQueryBuilder($objDatabase, 'table_item');
			TableItem::GetSelectFields($objQueryBuilder);
			$objQueryBuilder->AddFromItem('table_item');

			// Set "CountOnly" option (if applicable)
			if ($blnCountOnly)
				$objQueryBuilder->SetCountOnlyFlag();

			// Apply Any Conditions
			if ($objConditions)
				try {
					$objConditions->UpdateQueryBuilder($objQueryBuilder);
				} catch (QCallerException $objExc) {
					$objExc->IncrementOffset();
					throw $objExc;
				}

			// Iterate through all the Optional Clauses (if any) and perform accordingly
			if ($objOptionalClauses) {
				if ($objOptionalClauses instanceof QQClause)
					$objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
				else if (is_array($objOptionalClauses))
					foreach ($objOptionalClauses as $objClause)
						$objClause->UpdateQueryBuilder($objQueryBuilder);
				else
					throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
			}

			// Get the SQL Statement
			$strQuery = $objQueryBuilder->GetStatement();

			// Prepare the Statement with the Query Parameters (if applicable)
			if ($mixParameterArray) {
				if (is_array($mixParameterArray)) {
					if (count($mixParameterArray))
						$strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);

					// Ensure that there are no other Unresolved Named Parameters
					if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
						throw new QCallerException('Unresolved named parameters in the query');
				} else
					throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
			}

			// Return the Objects
			return $strQuery;
		}

		/**
		 * Static Qcubed Query method to query for a single TableItem object.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return TableItem the queried object
		 */
		public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = TableItem::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
			
			// Perform the Query, Get the First Row, and Instantiate a new TableItem object
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);
			
			// Do we have to expand anything?
			if ($objQueryBuilder->ExpandAsArrayNodes) {
				$objToReturn = array();
				while ($objDbRow = $objDbResult->GetNextRow()) {
					$objItem = TableItem::InstantiateDbRow($objDbRow, null, $objQueryBuilder->ExpandAsArrayNodes, $objToReturn, $objQueryBuilder->ColumnAliasArray);
					if ($objItem)
						$objToReturn[] = $objItem;					
				}			
				// Since we only want the object to return, lets return the object and not the array.
				return $objToReturn[0];
			} else {
				// No expands just return the first row
				$objToReturn = null;
				while ($objDbRow = $objDbResult->GetNextRow())
					$objToReturn = TableItem::InstantiateDbRow($objDbRow, null, null, null, $objQueryBuilder->ColumnAliasArray);
			}
			
			return $objToReturn;
		}

		/**
		 * Static Qcubed Query method to query for an array of TableItem objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return TableItem[] the queried objects as an array
		 */
		public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = TableItem::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and Instantiate the Array Result
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);
			return TableItem::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
		}

		/**
		 * Static Qcubed Query method to query for a count of TableItem objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return integer the count of queried objects as an integer
		 */
		public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = TableItem::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and return the row_count
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);

			// Figure out if the query is using GroupBy
			$blnGrouped = false;

			if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
				if ($objClause instanceof QQGroupBy) {
					$blnGrouped = true;
					break;
				}
			}

			if ($blnGrouped)
				// Groups in this query - return the count of Groups (which is the count of all rows)
				return $objDbResult->CountRows();
			else {
				// No Groups - return the sql-calculated count(*) value
				$strDbRow = $objDbResult->FetchRow();
				return QType::Cast($strDbRow[0], QType::Integer);
			}
		}

		public static function QueryArrayCached(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null, $blnForceUpdate = false) {
			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			$strQuery = TableItem::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			
			$objCache = new QCache('qquery/tableitem', $strQuery);
			$cacheData = $objCache->GetData();
			
			if (!$cacheData || $blnForceUpdate) {
				$objDbResult = $objQueryBuilder->Database->Query($strQuery);
				$arrResult = TableItem::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
				$objCache->SaveData(serialize($arrResult));
			} else {
				$arrResult = unserialize($cacheData);
			}
			
			return $arrResult;
		}

		/**
		 * Updates a QQueryBuilder with the SELECT fields for this TableItem
		 * @param QQueryBuilder $objBuilder the Query Builder object to update
		 * @param string $strPrefix optional prefix to add to the SELECT fields
		 */
		public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
			if ($strPrefix) {
				$strTableName = $strPrefix;
				$strAliasPrefix = $strPrefix . '__';
			} else {
				$strTableName = 'table_item';
				$strAliasPrefix = '';
			}

			$objBuilder->AddSelectItem($strTableName, 'id', $strAliasPrefix . 'id');
			$objBuilder->AddSelectItem($strTableName, 'itemname', $strAliasPrefix . 'itemname');
			$objBuilder->AddSelectItem($strTableName, 'itemnamejp', $strAliasPrefix . 'itemnamejp');
			$objBuilder->AddSelectItem($strTableName, 'description1', $strAliasPrefix . 'description1');
			$objBuilder->AddSelectItem($strTableName, 'description2', $strAliasPrefix . 'description2');
			$objBuilder->AddSelectItem($strTableName, 'price', $strAliasPrefix . 'price');
			$objBuilder->AddSelectItem($strTableName, 'tax_within', $strAliasPrefix . 'tax_within');
			$objBuilder->AddSelectItem($strTableName, 'license_day', $strAliasPrefix . 'license_day');
			$objBuilder->AddSelectItem($strTableName, 'subscription', $strAliasPrefix . 'subscription');
			$objBuilder->AddSelectItem($strTableName, 'image', $strAliasPrefix . 'image');
			$objBuilder->AddSelectItem($strTableName, 'simage', $strAliasPrefix . 'simage');
			$objBuilder->AddSelectItem($strTableName, 'suspend_date', $strAliasPrefix . 'suspend_date');
			$objBuilder->AddSelectItem($strTableName, 'suspended', $strAliasPrefix . 'suspended');
			$objBuilder->AddSelectItem($strTableName, 'active', $strAliasPrefix . 'active');
		}



		///////////////////////////////
		// INSTANTIATION-RELATED METHODS
		///////////////////////////////

		/**
		 * Instantiate a TableItem from a Database Row.
		 * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
		 * is calling this TableItem::InstantiateDbRow in order to perform
		 * early binding on referenced objects.
		 * @param DatabaseRowBase $objDbRow
		 * @param string $strAliasPrefix
		 * @param string $strExpandAsArrayNodes
		 * @param QBaseClass $arrPreviousItem
		 * @param string[] $strColumnAliasArray
		 * @return TableItem
		*/
		public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $arrPreviousItems = null, $strColumnAliasArray = array()) {
			// If blank row, return null
			if (!$objDbRow) {
				return null;
			}
			// See if we're doing an array expansion on the previous item
			$strAlias = $strAliasPrefix . 'id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (($strExpandAsArrayNodes) && is_array($arrPreviousItems) && count($arrPreviousItems)) {
				foreach ($arrPreviousItems as $objPreviousItem) {            
					if ($objPreviousItem->intId == $objDbRow->GetColumn($strAliasName, 'Integer')) {        
						// We are.  Now, prepare to check for ExpandAsArray clauses
						$blnExpandedViaArray = false;
						if (!$strAliasPrefix)
							$strAliasPrefix = 'table_item__';


						// Expanding reverse references: TableItemGetAsItem
						$strAlias = $strAliasPrefix . 'tableitemgetasitem__id';
						$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
						if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
							(!is_null($objDbRow->GetColumn($strAliasName)))) {
							if ($intPreviousChildItemCount = count($objPreviousItem->_objTableItemGetAsItemArray)) {
								$objPreviousChildItems = $objPreviousItem->_objTableItemGetAsItemArray;
								$objChildItem = TableItemGet::InstantiateDbRow($objDbRow, $strAliasPrefix . 'tableitemgetasitem__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
								if ($objChildItem) {
									$objPreviousItem->_objTableItemGetAsItemArray[] = $objChildItem;
								}
							} else {
								$objPreviousItem->_objTableItemGetAsItemArray[] = TableItemGet::InstantiateDbRow($objDbRow, $strAliasPrefix . 'tableitemgetasitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
							}
							$blnExpandedViaArray = true;
						}

						// Either return false to signal array expansion, or check-to-reset the Alias prefix and move on
						if ($blnExpandedViaArray) {
							return false;
						} else if ($strAliasPrefix == 'table_item__') {
							$strAliasPrefix = null;
						}
					}
				}
			}

			// Create a new instance of the TableItem object
			$objToReturn = new TableItem();
			$objToReturn->__blnRestored = true;

			$strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
			$objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'itemname', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'itemname'] : $strAliasPrefix . 'itemname';
			$objToReturn->strItemname = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'itemnamejp', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'itemnamejp'] : $strAliasPrefix . 'itemnamejp';
			$objToReturn->strItemnamejp = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'description1', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'description1'] : $strAliasPrefix . 'description1';
			$objToReturn->strDescription1 = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'description2', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'description2'] : $strAliasPrefix . 'description2';
			$objToReturn->strDescription2 = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'price', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'price'] : $strAliasPrefix . 'price';
			$objToReturn->intPrice = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'tax_within', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'tax_within'] : $strAliasPrefix . 'tax_within';
			$objToReturn->intTaxWithin = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'license_day', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'license_day'] : $strAliasPrefix . 'license_day';
			$objToReturn->intLicenseDay = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'subscription', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'subscription'] : $strAliasPrefix . 'subscription';
			$objToReturn->strSubscription = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'image', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'image'] : $strAliasPrefix . 'image';
			$objToReturn->strImage = $objDbRow->GetColumn($strAliasName, 'Blob');
			$strAliasName = array_key_exists($strAliasPrefix . 'simage', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'simage'] : $strAliasPrefix . 'simage';
			$objToReturn->strSimage = $objDbRow->GetColumn($strAliasName, 'Blob');
			$strAliasName = array_key_exists($strAliasPrefix . 'suspend_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'suspend_date'] : $strAliasPrefix . 'suspend_date';
			$objToReturn->dttSuspendDate = $objDbRow->GetColumn($strAliasName, 'DateTime');
			$strAliasName = array_key_exists($strAliasPrefix . 'suspended', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'suspended'] : $strAliasPrefix . 'suspended';
			$objToReturn->strSuspended = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'active', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'active'] : $strAliasPrefix . 'active';
			$objToReturn->strActive = $objDbRow->GetColumn($strAliasName, 'VarChar');

			if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
				foreach ($arrPreviousItems as $objPreviousItem) {
					if ($objToReturn->Id != $objPreviousItem->Id) {
						continue;
					}
					if (array_diff($objPreviousItem->_objTableItemGetAsItemArray, $objToReturn->_objTableItemGetAsItemArray) != null) {
						continue;
					}

					// complete match - all primary key columns are the same
					return null;
				}
			}

			// Instantiate Virtual Attributes
			foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
				$strVirtualPrefix = $strAliasPrefix . '__';
				$strVirtualPrefixLength = strlen($strVirtualPrefix);
				if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
					$objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
			}

			// Prepare to Check for Early/Virtual Binding
			if (!$strAliasPrefix)
				$strAliasPrefix = 'table_item__';




			// Check for TableItemGetAsItem Virtual Binding
			$strAlias = $strAliasPrefix . 'tableitemgetasitem__id';
			$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
			if (!is_null($objDbRow->GetColumn($strAliasName))) {
				if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
					$objToReturn->_objTableItemGetAsItemArray[] = TableItemGet::InstantiateDbRow($objDbRow, $strAliasPrefix . 'tableitemgetasitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
				else
					$objToReturn->_objTableItemGetAsItem = TableItemGet::InstantiateDbRow($objDbRow, $strAliasPrefix . 'tableitemgetasitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
			}

			return $objToReturn;
		}

		/**
		 * Instantiate an array of TableItems from a Database Result
		 * @param DatabaseResultBase $objDbResult
		 * @param string $strExpandAsArrayNodes
		 * @param string[] $strColumnAliasArray
		 * @return TableItem[]
		 */
		public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
			$objToReturn = array();
			
			if (!$strColumnAliasArray)
				$strColumnAliasArray = array();

			// If blank resultset, then return empty array
			if (!$objDbResult)
				return $objToReturn;

			// Load up the return array with each row
			if ($strExpandAsArrayNodes) {
				$objToReturn = array();
				while ($objDbRow = $objDbResult->GetNextRow()) {
					$objItem = TableItem::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objToReturn, $strColumnAliasArray);
					if ($objItem) {
						$objToReturn[] = $objItem;
					}
				}
			} else {
				while ($objDbRow = $objDbResult->GetNextRow())
					$objToReturn[] = TableItem::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
			}

			return $objToReturn;
		}



		///////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Single Load and Array)
		///////////////////////////////////////////////////
			
		/**
		 * Load a single TableItem object,
		 * by Id Index(es)
		 * @param integer $intId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem
		*/
		public static function LoadById($intId, $objOptionalClauses = null) {
			return TableItem::QuerySingle(
				QQ::AndCondition(
					QQ::Equal(QQN::TableItem()->Id, $intId)
				),
				$objOptionalClauses
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by Itemname Index(es)
		 * @param string $strItemname
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayByItemname($strItemname, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayByItemname query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->Itemname, $strItemname),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by Itemname Index(es)
		 * @param string $strItemname
		 * @return int
		*/
		public static function CountByItemname($strItemname) {
			// Call TableItem::QueryCount to perform the CountByItemname query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->Itemname, $strItemname)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by Itemnamejp Index(es)
		 * @param string $strItemnamejp
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayByItemnamejp($strItemnamejp, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayByItemnamejp query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->Itemnamejp, $strItemnamejp),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by Itemnamejp Index(es)
		 * @param string $strItemnamejp
		 * @return int
		*/
		public static function CountByItemnamejp($strItemnamejp) {
			// Call TableItem::QueryCount to perform the CountByItemnamejp query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->Itemnamejp, $strItemnamejp)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by Description1 Index(es)
		 * @param string $strDescription1
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayByDescription1($strDescription1, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayByDescription1 query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->Description1, $strDescription1),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by Description1 Index(es)
		 * @param string $strDescription1
		 * @return int
		*/
		public static function CountByDescription1($strDescription1) {
			// Call TableItem::QueryCount to perform the CountByDescription1 query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->Description1, $strDescription1)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by Description2 Index(es)
		 * @param string $strDescription2
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayByDescription2($strDescription2, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayByDescription2 query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->Description2, $strDescription2),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by Description2 Index(es)
		 * @param string $strDescription2
		 * @return int
		*/
		public static function CountByDescription2($strDescription2) {
			// Call TableItem::QueryCount to perform the CountByDescription2 query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->Description2, $strDescription2)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by Price Index(es)
		 * @param integer $intPrice
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayByPrice($intPrice, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayByPrice query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->Price, $intPrice),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by Price Index(es)
		 * @param integer $intPrice
		 * @return int
		*/
		public static function CountByPrice($intPrice) {
			// Call TableItem::QueryCount to perform the CountByPrice query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->Price, $intPrice)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by TaxWithin Index(es)
		 * @param integer $intTaxWithin
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayByTaxWithin($intTaxWithin, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayByTaxWithin query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->TaxWithin, $intTaxWithin),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by TaxWithin Index(es)
		 * @param integer $intTaxWithin
		 * @return int
		*/
		public static function CountByTaxWithin($intTaxWithin) {
			// Call TableItem::QueryCount to perform the CountByTaxWithin query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->TaxWithin, $intTaxWithin)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by LicenseDay Index(es)
		 * @param integer $intLicenseDay
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayByLicenseDay($intLicenseDay, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayByLicenseDay query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->LicenseDay, $intLicenseDay),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by LicenseDay Index(es)
		 * @param integer $intLicenseDay
		 * @return int
		*/
		public static function CountByLicenseDay($intLicenseDay) {
			// Call TableItem::QueryCount to perform the CountByLicenseDay query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->LicenseDay, $intLicenseDay)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by Subscription Index(es)
		 * @param string $strSubscription
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayBySubscription($strSubscription, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayBySubscription query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->Subscription, $strSubscription),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by Subscription Index(es)
		 * @param string $strSubscription
		 * @return int
		*/
		public static function CountBySubscription($strSubscription) {
			// Call TableItem::QueryCount to perform the CountBySubscription query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->Subscription, $strSubscription)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by SuspendDate Index(es)
		 * @param QDateTime $dttSuspendDate
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayBySuspendDate($dttSuspendDate, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayBySuspendDate query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->SuspendDate, $dttSuspendDate),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by SuspendDate Index(es)
		 * @param QDateTime $dttSuspendDate
		 * @return int
		*/
		public static function CountBySuspendDate($dttSuspendDate) {
			// Call TableItem::QueryCount to perform the CountBySuspendDate query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->SuspendDate, $dttSuspendDate)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by Suspended Index(es)
		 * @param string $strSuspended
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayBySuspended($strSuspended, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayBySuspended query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->Suspended, $strSuspended),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by Suspended Index(es)
		 * @param string $strSuspended
		 * @return int
		*/
		public static function CountBySuspended($strSuspended) {
			// Call TableItem::QueryCount to perform the CountBySuspended query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->Suspended, $strSuspended)
			);
		}
			
		/**
		 * Load an array of TableItem objects,
		 * by Active Index(es)
		 * @param string $strActive
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItem[]
		*/
		public static function LoadArrayByActive($strActive, $objOptionalClauses = null) {
			// Call TableItem::QueryArray to perform the LoadArrayByActive query
			try {
				return TableItem::QueryArray(
					QQ::Equal(QQN::TableItem()->Active, $strActive),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count TableItems
		 * by Active Index(es)
		 * @param string $strActive
		 * @return int
		*/
		public static function CountByActive($strActive) {
			// Call TableItem::QueryCount to perform the CountByActive query
			return TableItem::QueryCount(
				QQ::Equal(QQN::TableItem()->Active, $strActive)
			);
		}



		////////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Array via Many to Many)
		////////////////////////////////////////////////////




		//////////////////////////
		// SAVE, DELETE AND RELOAD
		//////////////////////////

		/**
		 * Save this TableItem
		 * @param bool $blnForceInsert
		 * @param bool $blnForceUpdate
		 * @return int
		 */
		public function Save($blnForceInsert = false, $blnForceUpdate = false) {
			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			$mixToReturn = null;

			try {
				if ((!$this->__blnRestored) || ($blnForceInsert)) {
					// Perform an INSERT query
					$objDatabase->NonQuery('
						INSERT INTO `table_item` (
							`itemname`,
							`itemnamejp`,
							`description1`,
							`description2`,
							`price`,
							`tax_within`,
							`license_day`,
							`subscription`,
							`image`,
							`simage`,
							`suspend_date`,
							`suspended`,
							`active`
						) VALUES (
							' . $objDatabase->SqlVariable($this->strItemname) . ',
							' . $objDatabase->SqlVariable($this->strItemnamejp) . ',
							' . $objDatabase->SqlVariable($this->strDescription1) . ',
							' . $objDatabase->SqlVariable($this->strDescription2) . ',
							' . $objDatabase->SqlVariable($this->intPrice) . ',
							' . $objDatabase->SqlVariable($this->intTaxWithin) . ',
							' . $objDatabase->SqlVariable($this->intLicenseDay) . ',
							' . $objDatabase->SqlVariable($this->strSubscription) . ',
							' . $objDatabase->SqlVariable($this->strImage) . ',
							' . $objDatabase->SqlVariable($this->strSimage) . ',
							' . $objDatabase->SqlVariable($this->dttSuspendDate) . ',
							' . $objDatabase->SqlVariable($this->strSuspended) . ',
							' . $objDatabase->SqlVariable($this->strActive) . '
						)
					');

					// Update Identity column and return its value
					$mixToReturn = $this->intId = $objDatabase->InsertId('table_item', 'id');
				} else {
					// Perform an UPDATE query

					// First checking for Optimistic Locking constraints (if applicable)

					// Perform the UPDATE query
					$objDatabase->NonQuery('
						UPDATE
							`table_item`
						SET
							`itemname` = ' . $objDatabase->SqlVariable($this->strItemname) . ',
							`itemnamejp` = ' . $objDatabase->SqlVariable($this->strItemnamejp) . ',
							`description1` = ' . $objDatabase->SqlVariable($this->strDescription1) . ',
							`description2` = ' . $objDatabase->SqlVariable($this->strDescription2) . ',
							`price` = ' . $objDatabase->SqlVariable($this->intPrice) . ',
							`tax_within` = ' . $objDatabase->SqlVariable($this->intTaxWithin) . ',
							`license_day` = ' . $objDatabase->SqlVariable($this->intLicenseDay) . ',
							`subscription` = ' . $objDatabase->SqlVariable($this->strSubscription) . ',
							`image` = ' . $objDatabase->SqlVariable($this->strImage) . ',
							`simage` = ' . $objDatabase->SqlVariable($this->strSimage) . ',
							`suspend_date` = ' . $objDatabase->SqlVariable($this->dttSuspendDate) . ',
							`suspended` = ' . $objDatabase->SqlVariable($this->strSuspended) . ',
							`active` = ' . $objDatabase->SqlVariable($this->strActive) . '
						WHERE
							`id` = ' . $objDatabase->SqlVariable($this->intId) . '
					');
				}

			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Update __blnRestored and any Non-Identity PK Columns (if applicable)
			$this->__blnRestored = true;


			// Return 
			return $mixToReturn;
		}

		/**
		 * Delete this TableItem
		 * @return void
		 */
		public function Delete() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Cannot delete this TableItem with an unset primary key.');

			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();


			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_item`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($this->intId) . '');
		}

		/**
		 * Delete all TableItems
		 * @return void
		 */
		public static function DeleteAll() {
			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_item`');
		}

		/**
		 * Truncate table_item table
		 * @return void
		 */
		public static function Truncate() {
			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				TRUNCATE `table_item`');
		}

		/**
		 * Reload this TableItem from the database.
		 * @return void
		 */
		public function Reload() {
			// Make sure we are actually Restored from the database
			if (!$this->__blnRestored)
				throw new QCallerException('Cannot call Reload() on a new, unsaved TableItem object.');

			// Reload the Object
			$objReloaded = TableItem::Load($this->intId);

			// Update $this's local variables to match
			$this->strItemname = $objReloaded->strItemname;
			$this->strItemnamejp = $objReloaded->strItemnamejp;
			$this->strDescription1 = $objReloaded->strDescription1;
			$this->strDescription2 = $objReloaded->strDescription2;
			$this->intPrice = $objReloaded->intPrice;
			$this->intTaxWithin = $objReloaded->intTaxWithin;
			$this->intLicenseDay = $objReloaded->intLicenseDay;
			$this->strSubscription = $objReloaded->strSubscription;
			$this->strImage = $objReloaded->strImage;
			$this->strSimage = $objReloaded->strSimage;
			$this->dttSuspendDate = $objReloaded->dttSuspendDate;
			$this->strSuspended = $objReloaded->strSuspended;
			$this->strActive = $objReloaded->strActive;
		}



		////////////////////
		// PUBLIC OVERRIDERS
		////////////////////

				/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'Id':
					/**
					 * Gets the value for intId (Read-Only PK)
					 * @return integer
					 */
					return $this->intId;

				case 'Itemname':
					/**
					 * Gets the value for strItemname 
					 * @return string
					 */
					return $this->strItemname;

				case 'Itemnamejp':
					/**
					 * Gets the value for strItemnamejp 
					 * @return string
					 */
					return $this->strItemnamejp;

				case 'Description1':
					/**
					 * Gets the value for strDescription1 
					 * @return string
					 */
					return $this->strDescription1;

				case 'Description2':
					/**
					 * Gets the value for strDescription2 
					 * @return string
					 */
					return $this->strDescription2;

				case 'Price':
					/**
					 * Gets the value for intPrice (Not Null)
					 * @return integer
					 */
					return $this->intPrice;

				case 'TaxWithin':
					/**
					 * Gets the value for intTaxWithin 
					 * @return integer
					 */
					return $this->intTaxWithin;

				case 'LicenseDay':
					/**
					 * Gets the value for intLicenseDay 
					 * @return integer
					 */
					return $this->intLicenseDay;

				case 'Subscription':
					/**
					 * Gets the value for strSubscription (Not Null)
					 * @return string
					 */
					return $this->strSubscription;

				case 'Image':
					/**
					 * Gets the value for strImage 
					 * @return string
					 */
					return $this->strImage;

				case 'Simage':
					/**
					 * Gets the value for strSimage 
					 * @return string
					 */
					return $this->strSimage;

				case 'SuspendDate':
					/**
					 * Gets the value for dttSuspendDate 
					 * @return QDateTime
					 */
					return $this->dttSuspendDate;

				case 'Suspended':
					/**
					 * Gets the value for strSuspended (Not Null)
					 * @return string
					 */
					return $this->strSuspended;

				case 'Active':
					/**
					 * Gets the value for strActive (Not Null)
					 * @return string
					 */
					return $this->strActive;


				///////////////////
				// Member Objects
				///////////////////

				////////////////////////////
				// Virtual Object References (Many to Many and Reverse References)
				// (If restored via a "Many-to" expansion)
				////////////////////////////

				case '_TableItemGetAsItem':
					/**
					 * Gets the value for the private _objTableItemGetAsItem (Read-Only)
					 * if set due to an expansion on the table_item_get.item_id reverse relationship
					 * @return TableItemGet
					 */
					return $this->_objTableItemGetAsItem;

				case '_TableItemGetAsItemArray':
					/**
					 * Gets the value for the private _objTableItemGetAsItemArray (Read-Only)
					 * if set due to an ExpandAsArray on the table_item_get.item_id reverse relationship
					 * @return TableItemGet[]
					 */
					return (array) $this->_objTableItemGetAsItemArray;


				case '__Restored':
					return $this->__blnRestored;

				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

				/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'Itemname':
					/**
					 * Sets the value for strItemname 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strItemname = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Itemnamejp':
					/**
					 * Sets the value for strItemnamejp 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strItemnamejp = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Description1':
					/**
					 * Sets the value for strDescription1 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strDescription1 = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Description2':
					/**
					 * Sets the value for strDescription2 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strDescription2 = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Price':
					/**
					 * Sets the value for intPrice (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intPrice = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'TaxWithin':
					/**
					 * Sets the value for intTaxWithin 
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intTaxWithin = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'LicenseDay':
					/**
					 * Sets the value for intLicenseDay 
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intLicenseDay = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Subscription':
					/**
					 * Sets the value for strSubscription (Not Null)
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strSubscription = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Image':
					/**
					 * Sets the value for strImage 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strImage = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Simage':
					/**
					 * Sets the value for strSimage 
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strSimage = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'SuspendDate':
					/**
					 * Sets the value for dttSuspendDate 
					 * @param QDateTime $mixValue
					 * @return QDateTime
					 */
					try {
						return ($this->dttSuspendDate = QType::Cast($mixValue, QType::DateTime));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Suspended':
					/**
					 * Sets the value for strSuspended (Not Null)
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strSuspended = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Active':
					/**
					 * Sets the value for strActive (Not Null)
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strActive = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}


				///////////////////
				// Member Objects
				///////////////////
				default:
					try {
						return parent::__set($strName, $mixValue);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Lookup a VirtualAttribute value (if applicable).  Returns NULL if none found.
		 * @param string $strName
		 * @return string
		 */
		public function GetVirtualAttribute($strName) {
			if (array_key_exists($strName, $this->__strVirtualAttributeArray))
				return $this->__strVirtualAttributeArray[$strName];
			return null;
		}



		///////////////////////////////
		// ASSOCIATED OBJECTS' METHODS
		///////////////////////////////

			
		
		// Related Objects' Methods for TableItemGetAsItem
		//-------------------------------------------------------------------

		/**
		 * Gets all associated TableItemGetsAsItem as an array of TableItemGet objects
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return TableItemGet[]
		*/ 
		public function GetTableItemGetAsItemArray($objOptionalClauses = null) {
			if ((is_null($this->intId)))
				return array();

			try {
				return TableItemGet::LoadArrayByItemId($this->intId, $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Counts all associated TableItemGetsAsItem
		 * @return int
		*/ 
		public function CountTableItemGetsAsItem() {
			if ((is_null($this->intId)))
				return 0;

			return TableItemGet::CountByItemId($this->intId);
		}

		/**
		 * Associates a TableItemGetAsItem
		 * @param TableItemGet $objTableItemGet
		 * @return void
		*/ 
		public function AssociateTableItemGetAsItem(TableItemGet $objTableItemGet) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateTableItemGetAsItem on this unsaved TableItem.');
			if ((is_null($objTableItemGet->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call AssociateTableItemGetAsItem on this TableItem with an unsaved TableItemGet.');

			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`table_item_get`
				SET
					`item_id` = ' . $objDatabase->SqlVariable($this->intId) . '
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objTableItemGet->Id) . '
			');
		}

		/**
		 * Unassociates a TableItemGetAsItem
		 * @param TableItemGet $objTableItemGet
		 * @return void
		*/ 
		public function UnassociateTableItemGetAsItem(TableItemGet $objTableItemGet) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableItemGetAsItem on this unsaved TableItem.');
			if ((is_null($objTableItemGet->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableItemGetAsItem on this TableItem with an unsaved TableItemGet.');

			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`table_item_get`
				SET
					`item_id` = null
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objTableItemGet->Id) . ' AND
					`item_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Unassociates all TableItemGetsAsItem
		 * @return void
		*/ 
		public function UnassociateAllTableItemGetsAsItem() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableItemGetAsItem on this unsaved TableItem.');

			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				UPDATE
					`table_item_get`
				SET
					`item_id` = null
				WHERE
					`item_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes an associated TableItemGetAsItem
		 * @param TableItemGet $objTableItemGet
		 * @return void
		*/ 
		public function DeleteAssociatedTableItemGetAsItem(TableItemGet $objTableItemGet) {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableItemGetAsItem on this unsaved TableItem.');
			if ((is_null($objTableItemGet->Id)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableItemGetAsItem on this TableItem with an unsaved TableItemGet.');

			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_item_get`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objTableItemGet->Id) . ' AND
					`item_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}

		/**
		 * Deletes all associated TableItemGetsAsItem
		 * @return void
		*/ 
		public function DeleteAllTableItemGetsAsItem() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTableItemGetAsItem on this unsaved TableItem.');

			// Get the Database Object for this Class
			$objDatabase = TableItem::GetDatabase();

			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`table_item_get`
				WHERE
					`item_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
		}





		////////////////////////////////////////
		// METHODS for SOAP-BASED WEB SERVICES
		////////////////////////////////////////

		public static function GetSoapComplexTypeXml() {
			$strToReturn = '<complexType name="TableItem"><sequence>';
			$strToReturn .= '<element name="Id" type="xsd:int"/>';
			$strToReturn .= '<element name="Itemname" type="xsd:string"/>';
			$strToReturn .= '<element name="Itemnamejp" type="xsd:string"/>';
			$strToReturn .= '<element name="Description1" type="xsd:string"/>';
			$strToReturn .= '<element name="Description2" type="xsd:string"/>';
			$strToReturn .= '<element name="Price" type="xsd:int"/>';
			$strToReturn .= '<element name="TaxWithin" type="xsd:int"/>';
			$strToReturn .= '<element name="LicenseDay" type="xsd:int"/>';
			$strToReturn .= '<element name="Subscription" type="xsd:string"/>';
			$strToReturn .= '<element name="Image" type="xsd:string"/>';
			$strToReturn .= '<element name="Simage" type="xsd:string"/>';
			$strToReturn .= '<element name="SuspendDate" type="xsd:dateTime"/>';
			$strToReturn .= '<element name="Suspended" type="xsd:string"/>';
			$strToReturn .= '<element name="Active" type="xsd:string"/>';
			$strToReturn .= '<element name="__blnRestored" type="xsd:boolean"/>';
			$strToReturn .= '</sequence></complexType>';
			return $strToReturn;
		}

		public static function AlterSoapComplexTypeArray(&$strComplexTypeArray) {
			if (!array_key_exists('TableItem', $strComplexTypeArray)) {
				$strComplexTypeArray['TableItem'] = TableItem::GetSoapComplexTypeXml();
			}
		}

		public static function GetArrayFromSoapArray($objSoapArray) {
			$objArrayToReturn = array();

			foreach ($objSoapArray as $objSoapObject)
				array_push($objArrayToReturn, TableItem::GetObjectFromSoapObject($objSoapObject));

			return $objArrayToReturn;
		}

		public static function GetObjectFromSoapObject($objSoapObject) {
			$objToReturn = new TableItem();
			if (property_exists($objSoapObject, 'Id'))
				$objToReturn->intId = $objSoapObject->Id;
			if (property_exists($objSoapObject, 'Itemname'))
				$objToReturn->strItemname = $objSoapObject->Itemname;
			if (property_exists($objSoapObject, 'Itemnamejp'))
				$objToReturn->strItemnamejp = $objSoapObject->Itemnamejp;
			if (property_exists($objSoapObject, 'Description1'))
				$objToReturn->strDescription1 = $objSoapObject->Description1;
			if (property_exists($objSoapObject, 'Description2'))
				$objToReturn->strDescription2 = $objSoapObject->Description2;
			if (property_exists($objSoapObject, 'Price'))
				$objToReturn->intPrice = $objSoapObject->Price;
			if (property_exists($objSoapObject, 'TaxWithin'))
				$objToReturn->intTaxWithin = $objSoapObject->TaxWithin;
			if (property_exists($objSoapObject, 'LicenseDay'))
				$objToReturn->intLicenseDay = $objSoapObject->LicenseDay;
			if (property_exists($objSoapObject, 'Subscription'))
				$objToReturn->strSubscription = $objSoapObject->Subscription;
			if (property_exists($objSoapObject, 'Image'))
				$objToReturn->strImage = $objSoapObject->Image;
			if (property_exists($objSoapObject, 'Simage'))
				$objToReturn->strSimage = $objSoapObject->Simage;
			if (property_exists($objSoapObject, 'SuspendDate'))
				$objToReturn->dttSuspendDate = new QDateTime($objSoapObject->SuspendDate);
			if (property_exists($objSoapObject, 'Suspended'))
				$objToReturn->strSuspended = $objSoapObject->Suspended;
			if (property_exists($objSoapObject, 'Active'))
				$objToReturn->strActive = $objSoapObject->Active;
			if (property_exists($objSoapObject, '__blnRestored'))
				$objToReturn->__blnRestored = $objSoapObject->__blnRestored;
			return $objToReturn;
		}

		public static function GetSoapArrayFromArray($objArray) {
			if (!$objArray)
				return null;

			$objArrayToReturn = array();

			foreach ($objArray as $objObject)
				array_push($objArrayToReturn, TableItem::GetSoapObjectFromObject($objObject, true));

			return unserialize(serialize($objArrayToReturn));
		}

		public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) {
			if ($objObject->dttSuspendDate)
				$objObject->dttSuspendDate = $objObject->dttSuspendDate->__toString(QDateTime::FormatSoap);
			return $objObject;
		}




	}



	/////////////////////////////////////
	// ADDITIONAL CLASSES for QCubed QUERY
	/////////////////////////////////////

	class QQNodeTableItem extends QQNode {
		protected $strTableName = 'table_item';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'TableItem';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'integer', $this);
				case 'Itemname':
					return new QQNode('itemname', 'Itemname', 'string', $this);
				case 'Itemnamejp':
					return new QQNode('itemnamejp', 'Itemnamejp', 'string', $this);
				case 'Description1':
					return new QQNode('description1', 'Description1', 'string', $this);
				case 'Description2':
					return new QQNode('description2', 'Description2', 'string', $this);
				case 'Price':
					return new QQNode('price', 'Price', 'integer', $this);
				case 'TaxWithin':
					return new QQNode('tax_within', 'TaxWithin', 'integer', $this);
				case 'LicenseDay':
					return new QQNode('license_day', 'LicenseDay', 'integer', $this);
				case 'Subscription':
					return new QQNode('subscription', 'Subscription', 'string', $this);
				case 'Image':
					return new QQNode('image', 'Image', 'string', $this);
				case 'Simage':
					return new QQNode('simage', 'Simage', 'string', $this);
				case 'SuspendDate':
					return new QQNode('suspend_date', 'SuspendDate', 'QDateTime', $this);
				case 'Suspended':
					return new QQNode('suspended', 'Suspended', 'string', $this);
				case 'Active':
					return new QQNode('active', 'Active', 'string', $this);
				case 'TableItemGetAsItem':
					return new QQReverseReferenceNodeTableItemGet($this, 'tableitemgetasitem', 'reverse_reference', 'item_id');

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

	class QQReverseReferenceNodeTableItem extends QQReverseReferenceNode {
		protected $strTableName = 'table_item';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'TableItem';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'integer', $this);
				case 'Itemname':
					return new QQNode('itemname', 'Itemname', 'string', $this);
				case 'Itemnamejp':
					return new QQNode('itemnamejp', 'Itemnamejp', 'string', $this);
				case 'Description1':
					return new QQNode('description1', 'Description1', 'string', $this);
				case 'Description2':
					return new QQNode('description2', 'Description2', 'string', $this);
				case 'Price':
					return new QQNode('price', 'Price', 'integer', $this);
				case 'TaxWithin':
					return new QQNode('tax_within', 'TaxWithin', 'integer', $this);
				case 'LicenseDay':
					return new QQNode('license_day', 'LicenseDay', 'integer', $this);
				case 'Subscription':
					return new QQNode('subscription', 'Subscription', 'string', $this);
				case 'Image':
					return new QQNode('image', 'Image', 'string', $this);
				case 'Simage':
					return new QQNode('simage', 'Simage', 'string', $this);
				case 'SuspendDate':
					return new QQNode('suspend_date', 'SuspendDate', 'QDateTime', $this);
				case 'Suspended':
					return new QQNode('suspended', 'Suspended', 'string', $this);
				case 'Active':
					return new QQNode('active', 'Active', 'string', $this);
				case 'TableItemGetAsItem':
					return new QQReverseReferenceNodeTableItemGet($this, 'tableitemgetasitem', 'reverse_reference', 'item_id');

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

?>